var powerMap = {
    "/front/admin/addProblem": 1,        //1 means problem power
    "/front/admin/problemList": 1,
    "/front/admin/updateProblem": 1,
    "/front/admin/contestList": 2,        //2 means contest power
    "/front/admin/addContest": 2,
    "/front/admin/updateContest": 2,
    "/front/admin/contestProblemList": 2,
    "/front/admin/contestUserList": 2,
    "/front/admin/contestUser": 2,
    "/front/admin/contestSolution": 2,
    "/front/admin/userList": 3,           //3 means user power
    "/front/admin/privilege": 3,
    "/front/admin/code": 3
}

blackList = ["/front/admin/index"];
function isInBlackList(str) {
    var len = blackList.length;
    for (var i=0; i<len; ++i) {
        if (blackList[i] == str) {
            return true;
        }
    }
    return false;
}

if (localStorage.getItem("token") != null) {
    checkPower(powerMap[window.location.pathname]);  //检查token对应用户的权限
}
else {
    var url = window.location.pathname;
    if (isInBlackList(url) == false) {
        location.href = "/front/index";
    }
}
